import json

from xjlibrary.our_file_dir import BaseDir

with open(BaseDir.get_new_path("allcover.big_json"), 'w', encoding="utf-8") as f:
    cnt = 0
    for filepath in BaseDir.get_dir_all_files(
            r"E:\样例数据\cnipapatent\cnipapatent_cover_new_raw_20190110\00027"):
        cnt += 1
        filename = BaseDir.get_filename_not_extsep(filepath)
        filepath = filepath.replace("E:\样例数据\cnipapatent\cnipapatent_cover_new_raw_20190110", "")
        filepath = "/smartlib" + filepath.replace("\\", "/")
        dicts = {"requestid": filename.upper(), "cover": filepath}
        jsonmsg = json.dumps(dicts, ensure_ascii=False)
        f.write(jsonmsg + "\n")
        if cnt % 500 == 1:
            print(cnt)